<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>监控中心 - 用户管理</title>

    <!-- Bootstrap Core CSS -->
    <link href="${request.getContextPath()}/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${request.getContextPath()}/public/dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${request.getContextPath()}/public/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!--嵌入头部跟菜单-->
        <#include "/admin/inc/menu.html"/>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <h4 class="page-header">用户列表</h4>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
        <!-- /.row -->
        <div class="row">

            <div class="col-lg-12">

                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>真实姓名</th>
                                    <th>登陆账号</th>
                                    <th>手机号码</th>
                                    <th>注册时间</th>
                                    <th>关联仓单数量</th>
                                </tr>
                            </thead>
                            <tbody>

                                <#if userList??>
                                <#list userList as user>
                                <tr>
                                    <td>${user.realName}</td>
                                    <td>${user.account}</td>
                                    <td>
                                        <#if user.phone!="">
                                            <button class="btn btn-default" data-toggle="modal" data-target="#myModal"
                                            onclick="setUserId(${user.id});">${user.phone}</button>
                                        </#if>

                                        <#if user.phone=="">
                                            <button class="btn btn-default" data-toggle="modal" data-target="#myModal" onclick="setUserId(${user.id});">添加</button>
                                        </#if>
                                    </td>
                                    <td>${user.registTime}</td>
                                    <td> <a href="${request.getContextPath()}/admin/user/choiseReceipt.do?userId=${user.id}" class="btn btn-default">${user.recepitNumber}</a> </td>
                                </tr>
                                </#list>
                                </#if>

                            </tbody>
                        </table>
                    </div>
                    <!-- /.table-responsive -->
                </div>

            </div>

        </div>
        <!-- /.row -->
                
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->


    <!-- Modal 用户手机号码修改 -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">编辑手机号码</h4>
                </div>
                <div class="modal-body">
                    <div class="row show-grid">
                        <input type="hidden" id="input-user-id" value="" />
                        <div class="col-md-12">说明：如果是删除现有手机号码，留空即可</div>
                        <div  class="col-md-12">手机号码：<input type="text" id="input-new-phone" /> </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="updatePhone();">保存</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->


    <!-- jQuery -->
    <script src="${request.getContextPath()}/public/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="${request.getContextPath()}/public/dist/js/sb-admin-2.js"></script>


    <script>


        function setUserId(userId){

            $("#input-user-id").val(userId);
        }


        //修改用户手机号码
        function updatePhone(){

            var phone = $("#input-new-phone").val();

            var userId = $("#input-user-id").val();

            //发送修改请求
            var url = "${request.getContextPath()}/admin/user/updatePhone.do";

            $.post(url,{userId:userId,phone:phone},function(data){

                alert(data.msg);

                //刷新页面
                location.reload();

            },"json");

        }


    </script>



</body>

</html>
